<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <script th:src="@{/}+'js/tool.js'"></script>
    <style type="text/css">
        .layui-form .layui-form-item{
            width:90%;
        }
        .layui-input-inline{
            width:300px!important
        }
    </style>

</head>
<body>
<div class="layui-tab layui-tab-brief" lay-filter="tabfilter">
    <ul class="layui-tab-title">
        <li class="layui-this">题目信息</li>
        <li>选项列表</li>
    </ul>
    <div class="layui-tab-content">
        <div class="layui-tab-item layui-show">
            <div th:replace="ksxt/lib/question-fr::info"></div>
        </div>
        <div class="layui-tab-item">
            <table class="layui-hide"  id="main-table" lay-filter="main-table"></table>
        </div>
    </div>
</div>

<script src="js/editor/ckeditor.js"></script>
<script>
    CKEDITOR.replace('tigan',
        {
            filebrowserImageUploadUrl: "/",
            height: 150
        });
    CKEDITOR.replace('jiexi',
        {
            filebrowserImageUploadUrl: "/",
            height: 150
        });
    var id = $("#id").val();
    layui.use(['form', 'table', 'laydate'], function(){
        var form = layui.form
            ,table = layui.table
            ,layer = layui.layer;
        createSelect("question-source","source",form,1,'请选择');
        createSelect("question-difficulty","difficulty",form,1,'请选择');
        createSelect("paper-type","contentType",form,1,'请选择');
        createSelect("paper-lg","lg",form,1,'请选择');
        window.selectParentChapter=function (data) {
            $("#chapterId").val(data.id)
            $("#chapterName").val(data.name)
        }
        table.render({
            elem: '#main-table'
            ,height: 640
            ,url: 'choice/getPageList'
            ,title: '选项列表'
            ,page: true
            ,where:{questionId :id||-1}
            ,cols: [
                [
                    {type: 'checkbox'}
                    ,{field: 'indexLetter',title: "索引",width:100}
                    ,{field: 'text', title: "文本"}

                    ,{field: 'rightTxt',title: "是否正确",width:90}
                    ,{field: 'answerText',title: "答案说明",width:290}
                ]
            ]
            ,done:function(){
                enableRowClick(table,form,'main-table',"main-table");
            }
        });

        if(id){
            loadData()
        }
        function loadData(){
            var entity = getEntityInfo(id,"question/getById");
            CKEDITOR.instances.tigan.setData(entity.text);
            CKEDITOR.instances.jiexi.setData(entity.analysis);
            form.val("myform",entity);
        }
        window.loadGrid = function (){
            table.reload("main-table");
        }

    })
</script>
</body>
</html>

</body>
</html>